import {request} from '../../request/index'
const app = getApp()

Page({
    data: {
        swiperList: [],
        catesList:[],
        goodsList:[],
    },
    goodsData:[],
    // 页面加载将会触发该函数
    onLoad: function() {
        this.getSwiperList()
        this.getCatesList()
        this.getGoodsList()
    },
    // 获取轮播图
    getSwiperList(){
        request({url:"http://localhost:8002/admin/swiper/all"}).then(res=>{
            this.setData({swiperList:res.data.data.all})
        })
    },
    // 获取楼层
    getCatesList(){
    request({url:"https://api-hmugo-web.itheima.net/api/public/v1/home/catitems"}).then(res=>{
        this.setData({catesList:res.data.message})
    })
    },
    //获取商品
    getGoodsList(){
        request({url:"http://localhost:8002/admin/goods/all"}).then(res=>{
            res.data.data.all.forEach(element=>{
                if(element.hotGoods==0){
                    this.goodsData.push(element)
                }
            })
            this.setData({goodsList:this.goodsData})
        })
    }
})